package com.atguigu.gulimail.order.vo;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author fangy
 * @date 2022-10-16 19:45
 */
@ToString
public class OrderConfirmVo {

    //收货地址，ums_member_receive_address
    @Getter @Setter
    List<MemberAddressVo> address;

    //所有选中项
    @Getter @Setter
    List<OrderItemVo> items;


    //优惠券信息
    @Getter @Setter
    Integer integration;


    //防重令牌
    @Setter @Getter
    String orderToken;



    public Integer getCount(){
        Integer i = 0 ;
        if(items!=null){
            for (OrderItemVo item : items) {
                i+=item.getCount();
            }
        }
        return i;
    }

//    //订单总额
//    @Getter
    BigDecimal total;

    public BigDecimal getTotal() {
        BigDecimal total = new BigDecimal("0");
        if(items !=null){
            for (OrderItemVo item :items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                total = total.add(multiply);
            }
        }
        return total;
    }


    //应付金额
    BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        return getTotal();
    }

}
